import 'dart:convert';
import 'package:ichinesereader/models/common/Settings.dart';

List<TeacherItem> teacherItemsFromJson(String str) => List<TeacherItem>.from(
    json.decode(str).map((x) => TeacherItem.fromJson(x)));

String teacherItemsToJson(List<TeacherItem> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class TeacherItem {
  TeacherItem({
    this.classId,
    this.className,
    this.classNames,
    this.disabled,
    this.email,
    this.firstName,
    this.lastLoggedIn,
    this.lastName,
    this.objectId,
    this.password,
    this.schoolAdmin,
    this.settings,
    this.status,
    this.totalAssignment,
    this.userName,
  });

  List<String>? classId;
  List<String>? className;
  String? classNames;
  bool? disabled;
  String? email;
  String? firstName;
  int? lastLoggedIn;
  String? lastName;
  String? objectId;
  String? password;
  String? schoolAdmin;
  Settings? settings;
  bool? status;
  int? totalAssignment;
  String? userName;

  factory TeacherItem.fromJson(Map<String, dynamic> json) => TeacherItem(
        classId: json["classId"] != null
            ? List<String>.from(json["classId"].map((x) => x))
            : null,
        className: json["className"] != null
            ? List<String>.from(json["className"].map((x) => x))
            : null,
        classNames: json["classNames"] != null ? json["classNames"] : '',
        disabled: json["disabled"],
        email: json["email"],
        firstName: json["firstName"],
        lastLoggedIn: json["lastLoggedIn"] ?? 0,
        lastName: json["lastName"],
        objectId: json["objectId"],
        password: json["password"],
        schoolAdmin: json["schoolAdmin"],
        settings: json["settings"] != null
            ? Settings.fromJson(json["settings"])
            : null,
        status: json["status"],
        totalAssignment: json["totalAssignment"],
        userName: json["userName"],
      );

  Map<String, dynamic> toJson() => {
        "classId":
            classId != null ? List<dynamic>.from(classId!.map((x) => x)) : null,
        "className": className != null
            ? List<dynamic>.from(className!.map((x) => x))
            : null,
        "classNames": classNames,
        "disabled": disabled,
        "email": email,
        "firstName": firstName,
        "lastLoggedIn": lastLoggedIn,
        "lastName": lastName,
        "objectId": objectId,
        "password": password,
        "schoolAdmin": schoolAdmin,
        "settings": settings != null ? settings?.toJson() : null,
        "status": status,
        "totalAssignment": totalAssignment,
        "userName": userName,
      };
}

// class Settings {
//     Settings({
//         this.audio,
//         this.dictionary,
//         this.id,
//         this.lang,
//         this.language,
//         this.music,
//         this.pinyin,
//         this.quizAudio,
//     });

//     bool audio;
//     bool dictionary;
//     String id;
//     String lang;
//     String language;
//     bool music;
//     bool pinyin;
//     bool quizAudio;

//     factory Settings.fromJson(Map<String, dynamic> json) => Settings(
//         audio: json["audio"],
//         dictionary: json["dictionary"],
//         id: json["id"],
//         lang: json["lang"],
//         language: json["language"],
//         music: json["music"],
//         pinyin: json["pinyin"],
//         quizAudio: json["quizAudio"],
//     );

//     Map<String, dynamic> toJson() => {
//         "audio": audio,
//         "dictionary": dictionary,
//         "id": id,
//         "lang": lang,
//         "language": language,
//         "music": music,
//         "pinyin": pinyin,
//         "quizAudio": quizAudio,
//     };
// }
